package com.sugon.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.PlanDraFileDao;
import com.sugon.entity.PlanDraFileEntity;
import com.sugon.service.PlanDraFileService;
import com.sugon.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 非标零件需求附件Service实现类
 *
 * @author sugon
 * @date 2019-08-13 10:50:09
 */
@Service("planDraFileService")
public class PlanDraFileServiceImpl implements PlanDraFileService {
    @Autowired
    private PlanDraFileDao planDraFileDao;

    @Override
    public PlanDraFileEntity queryObject(String id) {
        return planDraFileDao.queryObject(id);
    }

    @Override
    public List<PlanDraFileEntity> queryList(Map<String, Object> map) {
        return planDraFileDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return planDraFileDao.queryTotal(map);
    }

    @Override
    public int save(PlanDraFileEntity planDraFile) {
        planDraFile.setId(RandomUtil.randomString(32));
        planDraFile.setCreateUser(ShiroUtils.getUserId());
        planDraFile.setCreateDate(new Date());
        planDraFile.setDelFlag(1);

        return planDraFileDao.save(planDraFile);
    }

    @Override
    public int update(PlanDraFileEntity planDraFile) {
        planDraFile.setUpdateUser(ShiroUtils.getUserId());
        planDraFile.setUpdateDate(new Date());

        return planDraFileDao.update(planDraFile);
    }

    @Override
    public int delete(String id) {
        return planDraFileDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return planDraFileDao.deleteBatch(ids);
    }
}
